package com.cjm.one.goods.admin.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cjm.one.common.result.Result;
import com.cjm.one.goods.service.GoodsCommentTagService;
import com.cjm.one.model.goods.entity.GoodsCommentTag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@Tag(name = "商品评论标签", description = "商品评论标签")
@RequestMapping("/admin/goods/comment/tag")
public class GoodsCommentTagController {
    @Resource
    private GoodsCommentTagService goodsCommentTagService;

    @GetMapping("/list")
    @Operation(summary = "分页查询")
    public Result<Page<GoodsCommentTag>> list(@RequestParam("current") Long current, @RequestParam("size") Long size,@RequestParam(name = "keyword",required = false) String keyword) {
        return Result.ok(goodsCommentTagService.pageList(current, size, keyword)) ;
    }
    @DeleteMapping("/{id}")
    @Operation(summary = "删除")
    public Result<Boolean> delete(@PathVariable Long id) {
        return Result.ok(goodsCommentTagService.removeById(id));
    }
    @PostMapping
    @Operation(summary = "保存")
    public Result<Boolean> save(@RequestBody GoodsCommentTag goodsCommentTag) {

        return Result.ok(goodsCommentTagService.saveTag(goodsCommentTag));
    }
    @GetMapping("/{id}")
    @Operation(summary = "根据id查询")
    public Result<GoodsCommentTag> getById(@PathVariable Long id) {
        return Result.ok(goodsCommentTagService.getById(id));
    }
    @PutMapping
    @Operation(summary = "修改")
    public Result<Boolean> update(@RequestBody GoodsCommentTag goodsCommentTag) {
        return Result.ok(goodsCommentTagService.updateById(goodsCommentTag));
    }
}
